package com.dongdong.controller;


import com.dongdong.service.ItemCatService;
import com.dongdong.utils.PageBean;
import com.dongdong.utils.PageResult;
import com.dongdong.utils.Result;
import com.dongdong.vo.ItemCatVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/itemCat")
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    @PostMapping("/getItemCatPage")
    public Result getItemCatPage(@RequestBody PageBean<ItemCatVO> itemCatVO){
        PageResult<ItemCatVO> pageResult = itemCatService.getItemCatPage(itemCatVO);
        return Result.OK().setData(pageResult);
    }

    @GetMapping("/getItemCatByPid")
    public Result getItemCatByPid(@RequestParam Long pid){
        List<ItemCatVO> itemCatVOS = itemCatService.getItemCatByPid(pid);
        return Result.OK().setData(itemCatVOS);
    }

}
